Skip to main content

📡 HTTP Request

The HTTP Request feature in AppStruct allows you to connect your application to external APIs, enabling your app to communicate with other services, fetch data, and execute server-side actions.

This guide will walk you through the steps to effectively use the HTTP Request feature within AppStruct, providing you with the tools necessary to connect your app to a wide variety of external services and APIs.


Adding an HTTP Request Action​

  1. Navigate to the Canvas in your AppStruct workspace, where your device screen is displayed.
  2. Select the component to which you want to add an HTTP Request action (e.g., a button component).
  3. Once the component is selected, the Left Toolbar will appear.
  4. In the Left Toolbar, click on "Add Action" to open the list of available actions.

Configuring HTTP Request Parameters​

Step 1: Choose HTTP Request Action

  1. From the list of available actions, click on "HTTP Request".
  2. This will add a new node labeled HTTP Request under Click Actions.
  3. Click on it and it will open dropdown menu with select items.
  4. In the HTTP Request configuration, select the appropriate Request Method from the dropdown menu.
  • Available methods include:
    • GET: Retrieve data from a server.
    • POST: Send data to a server.
    • PUT: Update existing data on a server.
    • PATCH: Partially update existing data on a server
    • DELETE: Remove data from a server.
  1. Enter the URL:
  1. Configure the Request Body:
  • For POST or PUT requests, provide the Request Body in JSON format.

  • Enter key-value pairs representing the data you wish to send:

    {
    "username": "JohnDoe",
    "email": "[email protected]"
    }

Step 1: Save the Request

  1. After configuring the request, click the "Save" button at the bottom of the Left Toolbar to save the settings.
  2. Click on the "Preview" button in the Up Toolbar to enter preview mode.
  3. In the preview mode, interact with the component (e.g., click the button) to trigger the HTTP Request.
  4. Confirm that the request behaves as expected. If the request involves fetching data, ensure the data is displayed correctly in the UI.

Best Practices​

To maximize the effectiveness of using HTTP Requests in your AppStruct applications, consider the following best practices:

  1. Secure Your API Keys:
    • Do not expose sensitive API keys or secrets within client-side HTTP requests. Use secure methods to store and retrieve API keys where possible.
  2. Handle Errors Gracefully:
    • Implement error-handling logic to provide feedback to the user in case an HTTP request fails. For example, display an alert or error message when the server is unreachable.
  3. Throttle Requests:
    • Avoid making too many requests in a short period to prevent exceeding rate limits imposed by the server.
  4. Optimize for Performance:
    • When fetching large amounts of data, use pagination or filtering to reduce load times and improve the user experience.

Troubleshooting​

If you encounter issues when using the HTTP Request feature, refer to the troubleshooting guide below:

Issue 1: Request Failing with "401 Unauthorized"

  • Solution:
    • Verify that your API Key or Token is valid.

Issue 2: No Response from Server

  • Solution:
    • Double-check the URL for typos or incorrect formatting.
    • Ensure that the server is running and accessible.

Issue 3: Incorrect Data Being Returned

  • Solution:
    • Verify that the Request Body is correctly formatted in JSON.
    • Confirm that you are sending the correct parameters required by the API.

Need Assistance?​

If you encounter any challenges or require further guidance while building your app, please refer to the Documentation or, contact our support team at [email protected].


Happy Building with AppStruct!